<?php
declare (strict_types=1);

namespace app\mall\logic\address\admin;

use app\mall\model\address\admin\Address as AddressMod;
use think\Paginator;

/**
 * 后台地址逻辑层
 */
class Address extends AddressMod
{

    /**
     * 地址列表
     * Author: 亓官雨树 <lucky.max@foxmail.com>
     * Date: 22/11/30
     */
    public function addrList($map): Paginator
    {
        return $this->withJoin(['user_mhm'])->with(['username'])->where('userMhm.mhm_id', request()->mhm_id)->where($map)->order(['default' => 'DESC', 'update_time' => 'DESC'])->paginate(static::getListRows());
    }

    public function delAddrs($ids)
    {
        $this->whereIn('id', $ids)->select()->each(function ($i){
            $i->delete();
        });
    }
}